<?php
include "konek.php";
session_start();
if(isset($_SESSION['username']))
{
	$username=$_SESSION['username'];
}

/*file*/
$file1=$_POST['file1'];
$file2=$_POST['file2'];
$file3=$_POST['file3'];
$file4=$_POST['file4'];
$file5=$_POST['file5'];

/*posting*/
/*$cetak = mysql_query("select file from temp where author='$username' ");*/
$judul=$_POST['judul'];
$mapel=strtoupper($_POST['mapel']);
$kls=strtoupper($_POST['kls']);
$isi=mysql_real_escape_string($_POST['area']);
echo $isi;
$sql= mysql_query("insert into posting (judul, kelas, kategori, author, isi) values ('$judul','$kls','$mapel','$username','$isi')")or die(mysql_error()); 
$id=mysql_query("select idpost from posting where author='$username' and judul='$judul'");
$no=mysql_fetch_assoc($id);
$post=$no['idpost'];

/*simpan file*/
if(!is_null($file1))
{
	$save1=mysql_query("insert into file (id_post,nm_file) values ('$post','$file1')");
}

if(!is_null($file2))
{
	$save2=mysql_query("insert into file (id_post,nm_file) values ('$post','$file2')");
}
if(!is_null($file3))
{
	$save3=mysql_query("insert into file (id_post,nm_file) values ('$post','$file3')");
}

if(!is_null($file4))
{
	$save4=mysql_query("insert into file (id_post,nm_file) values ('$post','$file4')");
}

if(!is_null($file5))
{
	$save5=mysql_query("insert into file (id_post,nm_file) values ('$post','$file5')");
}
header('location:../pages/posting.php');